enum Keys {
    Token = 'token',
    UserId = 'userId',
    ExpireTime = 'expireTime'
}
//存储token到session
export const setTokens = (token: any) => {
    console.log("===>>>");
    
    localStorage.setItem(Keys.Token, token)
}
export const getToken = () => {
    return localStorage.getItem(Keys.Token)
}
//存储userId到sessionStorage
export const setUserId = (userId: number) => {
    sessionStorage.setItem(Keys.UserId, JSON.stringify(userId))
}

export const getUserId = () => {
    return sessionStorage.getItem(Keys.UserId)
}
//存储过期时间
export const setExpireTime = (time: number) => {
    localStorage.setItem(Keys.ExpireTime, JSON.stringify(time))
}
export const getExpireTime = () => {
    return localStorage.getItem(Keys.ExpireTime)
}
//session清空
export const cleanSession = () => {
    sessionStorage.clear()
    // 这个地方 需要清楚什么东西
    localStorage.removeItem('token')
    localStorage.removeItem('expireTime')
}

export const setStorage = (key: string, value: any) => {
    sessionStorage.setItem(key, JSON.stringify(value))
}
export const getStorage = (key: string,) => {
    let value = sessionStorage.getItem(key)
    if (value) {
        return JSON.parse(value)
    }
}